package com.xiang.adapter;

import java.util.List;

import com.xiang.seemovies.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CityAdapter extends BaseAdapter {
	private List<String> cityList;
	private LayoutInflater inflater;

	public CityAdapter(Context context, List<String> _cityList) {
		this.cityList = _cityList;
		inflater = LayoutInflater.from(context);
	}

	public void resetData(List<String> _cityList) {
		this.cityList = _cityList;
	}

	@Override
	public int getCount() {
		return cityList.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.city_adapter_layout, null);
			holder.city_name = (TextView) convertView.findViewById(R.id.txv_city_name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if(cityList.get(position)!=null){
			holder.city_name.setText(cityList.get(position));
		}
		return convertView;
	}

	class ViewHolder {
		TextView city_name;
	}
}
